/*
 * Copyright (C) 2012  Romain DUBOIS
 * 
 * This file is part of NeMoS - Network and Modular Software
 * 
 * NeMoS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * NeMoS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with NeMoS.  If not, see <http://www.gnu.org/licenses/>.
 */
package nemos.remote.rsa.message.data;

import java.util.ArrayList;
import java.util.Collection;

/**
 * InitMessage : The initialization message.
 * 
 * <p>
 * The server sends this message when a client connects in order to inform him
 * of already connected frameworks.
 * </p>
 * 
 * @author Romain DUBOIS
 */
public class InitMessage extends Message {

    /** Serial version */
    private static final long serialVersionUID = 1L;

    /** The label to use by the receiving transport in log messages */
    private final String mTransportLabel;

    /** The connected frameworks */
    private final Collection<String> mFrameworks;

    /**
     * Constructor
     * 
     * @param pLabel
     *            The target transport label
     */
    public InitMessage(final String pLabel) {
        super();
        mTransportLabel = pLabel;
        mFrameworks = null;
    }

    /**
     * Constructor
     * 
     * @param pLabel
     *            The target transport label
     * @param pFrameworks
     *            The connected frameworks
     */
    public InitMessage(final String pLabel, final Collection<String> pFrameworks) {
        super();
        mTransportLabel = pLabel;
        mFrameworks = new ArrayList<String>(pFrameworks);
    }

    /**
     * Get the connected frameworks UUIDs.
     * 
     * @return The connected frameworks UUIDs
     */
    public Collection<String> getConnectedFrameworks() {
        return mFrameworks;
    }

    /**
     * Get the transport label.
     * 
     * @return The transport label
     */
    public String getTransportLabel() {
        return mTransportLabel;
    }

    /**
     * {@inheritDoc}
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        final StringBuilder lBuilder = new StringBuilder(super.toString());
        lBuilder.append('-').append(mTransportLabel);
        lBuilder.append(mFrameworks);
        return lBuilder.toString();
    }
}
